#!/usr/bin/env python3

import scrapy

class getSignSpider(scrapy.Spider):
    name = "getSign"
    start_urls = [
        "http://www.qqgexingqianming.com",
    ]

    allowed_domains = [
        "www.qqgexingqianming.com",
    ]


    def parse(self, response):
        with open("sign.txt", "a+") as fp:
            for p in response.xpath("//ul[@id='list2']//p"):
                text = p.xpath("./text()").extract_first()
                if text is None:
                    continue
                fp.write(text+"\n")
                fp.flush()

        for url in response.xpath("//div[@class='hdbox']/div[@class='hd-tab']/a/@href").extract():
            url = response.urljoin(url)
            yield scrapy.Request(url=url, callback=self.parse)



